Music Object Instance Properties
|
|
| Property Name |
Short Description |
| Player State |
| locked |
A boolean value, indicating whether or not a player instance is permitted to respond to methods that change its state. |
| ready |
A boolean value, indicating whether or not a player instance is ready to receive scripting control. |
| General |
| audible |
A boolean value, indicating whether or not the Music Object instance is considered audible. |
| averageNoteRelease |
An integer value, representing the average release time (measured in milliseconds) for notes being played through a Music Object instance. |
| usage |
A string value, specifying the purpose for which the Music Object instance is being used. |
|
|
The locked property provides a way to disallow (or allow) the state of a Music Object instance to be changed.
When this property is set to true, any attempts to alter the state of the Music Object instance are effectively blocked. In this condition, it is still possible to obtain state information about the instance using the "get" type methods, but it is not possible to alter the state of the instance using the "set" type methods or the transport control methods, such as play, pause, and stop. This is a convenient way to switch off certain aspects of the sonification of a page's user interface, since all attempts to instruct an instance to play musical notes, Groovoids, or music files will be blocked when its locked property is set true.
It's important to note that setting this property to true will not stop music that is currently playing through the instance, but will merely block further attempts to change the state of the instance. So, depending on the way you wish to use this property, you may need to use the stop method before setting the locked property to true. Of course, if you first set the property to true and then try to use the stop method, you will not succeed in stopping the music that's playing because having the property set to true will block all attempts to change the state of the instance, including attempts to stop it playing.
Compare this instance property to the Music.enabled static property, which can be used as a master switch to enable or disable sonification across all Music Object instances.
The ready instance property is a boolean variable, indicating whether or not a player instance is ready to receive scripting control.
When this property has a value of true, then the instance is ready for scripting, and when the property has a value of false, the instance is not yet ready for scripting control. This property replaces the isReady method that was supported in versions of Music Object earlier than 3.1.0.
It is also possible (and often more advisable) to determine when an instance becomes ready by registering a callback handler for the ready event using the onReady or addOnReady methods. Using the callback approach, there is no guesswork involved as the ready event is only triggered when the player instance becomes ready for scripting control - no sooner and no later.
The audible instance property is a boolean variable, indicating whether or not the Music Object instance is considered audible.
The behavior of this property is affected by the values of the usage and averageNoteRelease instance properties.
The audible property will be set to true in the following cases...
- The usage instance property is set to the string value "music", the Music Object instance is in a playing state (not paused or stopped), and its output volume (which can be queried using the getOutputVolume instance method) is greater than 0.
- The usage instance property is set to the string value "notes", the Music Object instance is in a playing state (not paused or stopped), its output volume is greater than 0, and there are one or more notes that were triggered through the note playing methods of the Music Object API (eg. noteOn, playNote, playRandomNote, playChord, etc.) that are still on, or all notes that were triggered through the note playing methods have been turned off but the amount of time specified by the averageNoteRelease instance property has not yet elapsed since the last remaining note was turned off.
It is important to note that the Music Object API does not take into account the settings for channel volume, track mute, track solo, channel mute, or channel solo when determining whether or not an instance is audible. So, it is possible for an instance to have no audio output (as a result of all the tracks being muted, for example), but for the audible property still to be set to true. This is a limitation that you should keep in mind if you are designing more sophisticated interactive audio applications.

The averageNoteRelease instance property is an integer variable, representing the average release time (measured in milliseconds) for notes being played through a Music Object instance.
When a Music Object instance is in a playing state (not paused or stopped), its output volume (which can be queried using the getOutputVolume instance method) is greater than 0, and the usage instance property is set to the string value "notes", then the value of the averageNoteRelease property will determine how long it takes, after all notes that were triggered via scripting have been turned off, for the instance to no longer be considered audible (ie. the value of the audible instance property becomes false).
In the example shown in the illustration below, three notes are being triggered. The first note being triggered has a duration of 2500 milliseconds. The second note, which also has a duration of 2500 milliseconds, is being triggered 500 milliseconds after the first note. Finally, a third note with a duration of 1500 milliseconds is being triggered 750 milliseconds after the first note.

Because of the timing and duration of the notes, it actually turns out that the second note that is triggered will be the last of the notes to be turned off, and it will be turned off 3000 milliseconds after the first note is turned on. Now, in this example the averageNoteRelease property is set to 1000, so the value of the audible property will become false exactly 1000 milliseconds later, which is 4000 milliseconds after the first note is triggered.

- The value of the averageNoteRelease property only affects the behavior of the audible instance property when the usage instance property is set to "notes". So, if the usage property is set "music", then the averageNoteRelease property has no effect.
The usage instance property is a string variable, specifying the purpose for which the Music Object instance is being used.
The value set for this property is used in determining whether or not the Music Object instance is audible, and affects the behavior of the audible instance property.
There are two possible values for this property...
- "music"
Indicates that the instance is being used to play music files. When this value is set for the usage property, the audible instance property will be set to true whenever the instance is in a playing state (not paused or stopped) and the output volume (which can be queried using the getOutputVolume instance method) is greater than 0.
- "notes"
Indicates that the instance is being used exclusively to play musical notes (possibly for user interface sounds) through the note playing methods of the Music Object API (eg. noteOn, playNote, playRandomNote, playChord, etc.). When this value is set for the usage property, then the audible instance property will only be set to true when the instance is in a playing state (not paused or stopped), the output volume is greater than 0, and there are one or more notes that were triggered through the note playing methods that are still on, or all notes that were triggered through the note playing methods have been turned off but the amount of time specified by the averageNoteRelease instance property has not yet elapsed since the last remaining note was turned off.